function fitness = fical(x)
    num_dim = evalin('base', 'num_dim');  
    num_class = evalin('base', 'num_class');
    p_train = evalin('base', 'p_train');
    t_train = evalin('base', 't_train');
    T_train = evalin('base', 'T_train');
best_hd  = round(x(1, 2));
best_lr= x(1, 1);
best_l2 = x(1, 3);

lgraph = layerGraph();
tempLayers = [
    sequenceInputLayer([num_dim, 1, 1], "Name", "input_sequence")
    sequenceFoldingLayer("Name", "seqfold_layer")];
lgraph = addLayers(lgraph, tempLayers);
tempLayers = convolution2dLayer([3, 1], 32, "Name", "conv_1");
lgraph = addLayers(lgraph, tempLayers);
tempLayers = [
    reluLayer("Name", "relu_1")
    convolution2dLayer([3, 1], 64, "Name", "conv_2")
    reluLayer("Name", "relu_2")];
lgraph = addLayers(lgraph, tempLayers);
tempLayers = [
    globalAveragePooling2dLayer("Name", "gapool")
    fullyConnectedLayer(16, "Name", "fc_2")
    reluLayer("Name", "relu_3")
    fullyConnectedLayer(64, "Name", "fc_3")
    sigmoidLayer("Name", "sigmoid")];
lgraph = addLayers(lgraph, tempLayers);

tempLayers = multiplicationLayer(2, "Name", "multiplication");
lgraph = addLayers(lgraph, tempLayers);
tempLayers = [
    sequenceUnfoldingLayer("Name", "sequnfold_layer")
    flattenLayer("Name", "flatten")
    lstmLayer(best_hd, "Name", "lstm", "OutputMode", "last")
    fullyConnectedLayer(num_class, "Name", "fc_final")
    softmaxLayer("Name", "softmax")
    classificationLayer("Name", "classification")];
lgraph = addLayers(lgraph, tempLayers);
lgraph = connectLayers(lgraph, "seqfold_layer/out", "conv_1");
lgraph = connectLayers(lgraph, "seqfold_layer/miniBatchSize", "sequnfold_layer/miniBatchSize");
lgraph = connectLayers(lgraph, "conv_1", "relu_1");
lgraph = connectLayers(lgraph, "conv_1", "gapool");
lgraph = connectLayers(lgraph, "relu_2", "multiplication/in2");
lgraph = connectLayers(lgraph, "sigmoid", "multiplication/in1");
lgraph = connectLayers(lgraph, "multiplication", "sequnfold_layer/in");
options = trainingOptions('adam', ...
    'MaxEpochs', 500, ...
    'InitialLearnRate', best_lr, ...
    'L2Regularization', best_l2, ...
    'LearnRateSchedule', 'piecewise', ...
    'LearnRateDropFactor', 0.1, ...
    'LearnRateDropPeriod', 400, ...
    'Shuffle', 'every-epoch', ...
    'ValidationPatience', Inf, ...
    'Plots', 'training-progress', ...
    'Verbose', false);
net = trainNetwork(p_train, t_train, lgraph, options);
t_sim1 = predict(net, p_train); 
T_sim1 = vec2ind(t_sim1');
fitness = 1-sum((T_sim1 == T_train))/length(T_train) ;

end